import Vue from 'vue'
import Router from 'vue-router'

// 引入组件
import HelloWorld from '@/components/HelloWorld'
import home from '../components/home'
import about from '../components/about.vue'
import aaaaa from '../components/aaaaa'
import b from '../components/b'
Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/home',
      name: '/home',
      component: home
    },
    {
      path: '/about',
      name: '/about',
      component: about
    },
    {
      path: '/aaaaa',
      name: '/aaaaa',
      component: aaaaa
    },
    {
      path: '/b',
      name: '/b',
      component: b
    }
  ]
})

router.beforeEach((to, from, next) => {
  console.log(to)
  console.log(from)
  if (from.path !== '/') {
    console.log('router.go刷新页面重进')
    router.go({name: to.path, params: {timestamp: new Date().getTime()}})
  }
  next()
})

export default router
